<?php

class Admin_Form_Parcelamento extends Zend_Form
{

    public function init()
    {
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $module = $front->getRequest()->getModuleName();
        $id = $front->getRequest()->getParam('id',0);
        $mat_id = $front->getRequest()->getParam('mat_id',0);
        $url = $front->getBaseUrl().'/'.$module.'/'.$controller.'/index/mat_id/'.$mat_id;
       
        Zend_Loader::loadClass('tools','library');
        
        $this->setName('form_'.$controller);
        
        $el = new Zend_Form_Element_Hidden('MAT_ID',array('disableLoadDefaultDecorators' =>true));
        $el->addDecorators(array(array('ViewHelper'),array('Errors')))->addFilter('Int');
        $this->addElement($el);
       
        $el = new Zend_Form_Element_Text('PAR_NUM');
        $el->setLabel('Número da Parcela')//->setRequired(true)
        ->addFilters(array('StripTags','StringTrim'))
        ->addValidator('NotEmpty');
        $el->setAttrib('class','numero');
        $el->setAttrib('readonly',true);
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Text('PAR_DAT');
        $el->setLabel('Data')->setRequired(true)
        ->addFilters(array('StripTags','StringTrim'))
        ->addValidator('NotEmpty');
        $el->setAttrib('class','data');
        $el->setAttrib('required','');
        if($id > 0){
            $el->setAttrib('readonly',true);
        }else{
            $el->setAttrib('class','data jqdata');
        }
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('CUR_NOM');
        $el->setLabel('Curso');
        $el->setAttrib('readonly',true);
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('FOR_NOM');
        $el->setLabel('Forma de Pagamento');
        $el->setAttrib('readonly',true);
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('ALU_NOM');
        $el->setLabel('Aluno');
        $el->setAttrib('readonly',true);
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PAR_VLR');
        $el->setLabel('Valor');
        $el->setAttrib('readonly',true);
        $el->setAttrib('class','valor');
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Radio('PAR_STAPGO',array());
        $el->setLabel('')
        ->setRequired(true)
        ->addValidator('NotEmpty')
        ->addMultiOptions(tools::getStatusPag());
        $this->addElement($el);
        
        
        /*
        $el = new Zend_Form_Element_Checkbox('PAR_STA',array('checked'=>'checked'));
        $el->setLabel('Status');
        $this->addElement($el);
        */
        $btn = new Zend_Form_Element_Submit('Salvar',array('disableLoadDefaultDecorators' =>true));
        $btn->addDecorators(array(array('ViewHelper'),array('Errors')));
        $btn->setLabel('Salvar');
        $btn->setAttrib('id', 'submitbutton');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);
        
        $btn = new Zend_Form_Element_Button('Cancelar',array('disableLoadDefaultDecorators' =>true));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<a href="'.$url.'" class="btn-frm">Voltar</a>');
        $btn->setAttrib('id', 'btncancel');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);
    }


}

